#include <iostream>
#include <queue>
#include <string>
using namespace std;

const int kMaxN = 2e5 + 10;

bool vis[2][kMaxN];
string g[2];
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

bool BFS(int n) {
  queue<int> q;

  fill(vis[0], vis[0] + n, false);
  fill(vis[1], vis[1] + n, false);
  vis[0][0] = true;
  q.emplace(0);
  while (!q.empty()) {
    int nowx = q.front() & 1, nowy = q.front() >> 1;

    q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = nowx + dir[i][0], ny = nowy + dir[i][1];

      if (nx >= 0 && nx < 2 && ny >= 0 && ny < n) {
        if (g[nx][ny] == '>') {
          ny++;
        } else {
          ny--;
        }
        if (vis[nx][ny]) {
          continue;
        }
        vis[nx][ny] = true;
        q.emplace((ny << 1) + nx);
      }
    }
  }
  return vis[1][n - 1];
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  for (cin >> T; T; T--) {
    int n;
    cin >> n >> g[0] >> g[1];
    cout << (BFS(n) ? "YES\n" : "NO\n");
  }
  return 0;
}